cssbgsizevalue: Avoid allocating new value if not needed
authorBenjamin Otte <otte@redhat.com>
Thu, 21 Apr 2016 20:28:14 +0000 (22:28 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 21 Apr 2016 21:01:31 +0000 (23:01 +0200)
gtk/gtkcssbgsizevalue.c

index b5da0677d0b1f7b66c524835ebb64f7232143ee9..3e25ded7585261bd8b9ed4bfa2d4d6b07a9a1846 100644 (file)
@@ -60,6 +60,16 @@ gtk_css_value_bg_size_compute (GtkCssValue             *value,
   if (value->y)
     y = _gtk_css_value_compute (value->y, property_id, provider, style, parent_style);
 
+  if (x == value->x && y == value->y)
+    {
+      if (x)
+        _gtk_css_value_unref (x);
+      if (y)
+        _gtk_css_value_unref (y);
+
+      return _gtk_css_value_ref (value);
+    }
+
   return _gtk_css_bg_size_value_new (value->x ? x : NULL,
                                      value->y ? y : NULL);
 }